
package com.yimixian.app.model;

import com.ta.utdid2.android.utils.StringUtils;
import com.yimixian.app.util.UiUtils;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

public class AppConfig implements Serializable{

    public String cartGiftTitle;
    public String bonusUrl;
    public String rechargeUrl;
    public String staticDomain;
    public String pixer;
    public String creditMallUrl;//个人资料积分
    public String agreementUrl; //协议书的URL地址
    public String customerServiceTel;//客服联系
    public String invitationUrl;//邀请好友大礼包
    public String enterpriseBuyingGroup;//企业团购
    public String buyingGroupPlacesUrl;//我的团订单
    public String imgUrlFormat;// "{domain}{image}?/XXX/XXX#{width}", // 客户端使用该字段进行匹配，声称最终图片URL
    public String confirmOrderMessage;
    public boolean shouldShowMap;
    public AppVersion appVersion;
    public List<Region> regions;
    public HashMap<String, String> mPaymentMethodTitles;
    public String serviceTermsUrl;//服务条款
    public List<String> cookieDomains;//

    //2.0.1
    public String memberIntroUrl = "";//会员等级的介绍网页链接

    //2.2.0
    public List<Entries> userCenterEntries; //我的页面底部数据动态配置
    public Maintenance maintenance; //维护相关信息

    //2.2.1
    public String regions_url; //省市县(区)关联信息 请求地址
    public String regions_version; //区域版本号与上次不同则重新更新下载
    public String login_by_wechat; //是否显示微信联合登录按钮

    public int getProvice(String city){
        int provinceIndex = 0;
        if (regions == null || regions.size() <= 0
                ||StringUtils.isEmpty(city)) return provinceIndex;
        for (int i = 0; i < regions.size(); i++){
            int mProvinceIndex = i;
            List<City> citys = regions.get(i).cities;
            if (citys != null && citys.size() > 0) {
                for (City mCity : citys){
                    if (UiUtils.isCompareCity(mCity.name, city)){
                        provinceIndex = mProvinceIndex;
                        return provinceIndex;
                    }
                }
            }
        }
        return provinceIndex;
    }

    public String getProviceName(String city){
        String province = "";
        if (regions == null || regions.size() <= 0
                ||StringUtils.isEmpty(city)) return province;
        for (int i = 0; i < regions.size(); i++){
            String mProvinceIndex = regions.get(i).name;
            List<City> citys = regions.get(i).cities;
            if (citys != null && citys.size() > 0) {
                for (City mCity : citys){
                    if (UiUtils.isCompareCity(mCity.name, city)){
                        province = mProvinceIndex;
                        return province;
                    }
                }
            }
        }
        return province;
    }
}
